<!DOCTYPE html>
<html>
<!-- Mirrored from www.zi-han.net/theme/hplus/table_jqgrid.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:02 GMT -->

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加盟商家</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">

    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <!--图片插件-->
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/newStyle.css" rel="stylesheet">

    <style>
        /* 重写bookstrap样式表 勿删 */
        .ibox-title {
            padding: 20px;
        }

        .ui-jqdialog {
            height: auto !important;
        }

        .ui-common-table tbody {
            background-color: #eaf5fc !important;
        }

        .modal-dialog {
            margin: 80px auto !important;
        }

        .form-group {
            margin-left: 0px !important;
            margin-right: 0px !important;
        }

        .modal-sm {
            width: 600px;
        }

        .col-sm-3 {
            width: 30%;
        }

        .col-sm-8 {
            width: 70%;
        }

        .form-horizontal .control-label {
            text-align: left;
            padding-top: 5px;
            font-size: 18px;
        }

        @media only screen and (min-width: 100px) and (max-width: 600px) {
            .modal-sm {
                width: 400px;
            }

            .col-sm-3 {
                width: 40%;
            }

            .col-sm-8 {
                width: 60%;
            }

            .scroll_div {
                width: 85%;
            }

            .form-horizontal .control-label {
                text-align: left;
                padding-top: 5px;
                font-size: 14px;
            }

            .dialog_btn {
                font-size: 14px !important;
            }
        }

        @media only screen and (min-width: 650px) {
            .modal-sm {
                width: 600px;
            }
        }

        .note-editable {
            min-height: 200px;
        }

        /*编辑器的输入区域的最小高度*/
        /*以下是等待状态的通用样式*/
        .wating_big_div {
            position: fixed;
            top: 0px;
            width: 100%;
            height: 100%;
            display: table;
            z-index: 9999;
        }

        .zhezhao {
            opacity: 0.3;
            position: absolute;
            top: 0px;
            width: 100%;
            height: 100%;
            z-index: 9999;
        }

        .wating_content_div {
            text-align: center;
            background: none;
            display: table-cell;
            vertical-align: middle;
        }

        a {
            margin-right: 10px;
        }

        .picture_click {
            background: url(http://sandbox.runjs.cn/uploads/rs/382/gzpur0hb/select-default.png) no-repeat;
            opacity: 1;
            width: 15px;
            height: 8px;
            position: absolute;
            top: 15px;
            right: 20px;
            /*margin-top: -4px;*/
            cursor: pointer;
        }

        .picture_click:hover {
            background-image: url(http://sandbox.runjs.cn/uploads/rs/382/gzpur0hb/select-hover.png);
        }

        .selectList {
            width: 93%;
            height: 212px;
            overflow-y: scroll;
            text-align: left;
            /*margin: 0 172px;*/
            border: 1px solid rgb(229, 230, 231);
            display: none;
            position: absolute;
            background: #fff;
            top: 35px;
            overflow-y: scroll;
            padding: 6px 12px;
            left: 50%;
            transform: translateX(-50%);
            -moz-transform: translateX(-50%);
            -webkit-transform: translateX(-50%);
            z-index: 2;
        }

        .selectList div {
            cursor: pointer;
        }

        .selectList1 {
            width: 93%;
            height: 212px;
            overflow-y: scroll;
            text-align: left;
            /*margin: 0 172px;*/
            border: 1px solid rgb(229, 230, 231);
            display: none;
            position: absolute;
            background: #fff;
            top: 35px;
            overflow-y: scroll;
            padding: 6px 12px;
            left: 50%;
            transform: translateX(-50%);
            -moz-transform: translateX(-50%);
            -webkit-transform: translateX(-50%);
            z-index: 2;
        }

        .selectList1 div {
            cursor: pointer;
        }

        /*以上是等待状态的通用样式*/
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title pull-left w100p" style="padding: 10px 20px;">
                        <div class="pull-left">
                            <div class="ibox-tools cache5">
                                甄选商品
                            </div>
                        </div>

                        <div class="pull-right">
                            <button class="refresh_btn">
                                <a class="refresh_a" style="">
                                    <i class="fa fa-refresh"></i> 刷新
                                </a>
                            </button>
                        </div>
                    </div>
                    <div class="ibox-content pull-left w100p">
                        <div class="w100p chaxunBorder">
                            <div class="ibox-title w100p"
                                style="height:50px;background-color: rgb(243, 243, 243);padding: 10px 20px;border-top:0px;">
                                <div class="ibox-tools pull-left">
                                    <span class="titleFindIcon pull-left"></span>
                                    <span class="pull-left" style="position: relative;top: 3px;left: 5px;">筛选查询</span>
                                </div>
                                <div class="pull-right">
                                    <button class="opera_btn querybtn" id="check_btn">查询结果</button>
                                </div>
                            </div>
                            <div class="w100p p20" style="display: flex;background-color: #ffffff">
                                <div class="ml30">
                                    <span class="f14 pull-left h30 lh30">输入搜索：</span>
                                    <div class="pull-left">
                                        <input type="text" placeholder="输入商品名称"
                                            class="form-control h30 w100p ml10 queryInput" style="width: 150px;"
                                            id="check_arg1_input" placeholder="商家名称/商品货号" aria-required="true">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-content pull-left w100p">
                            <div class="ibox-title pull-left w100p table-head"
                            style="background-color: rgb(243, 243, 243);padding: 10px 20px;border-top:0px;">
                            <div class="pull-left">
                                <div class="ibox-tools" style="">
                                    <span class="titleFontIcon"></span>
                                    <span class="pull-left" style="position: relative;top: 3px;left: 5px;">数据列表</span>
                                </div>
                            </div>
                            <div class="pull-right">
                                <button class="opera_btn addbtn" data-toggle="modal" data-target="#add_dialog">新增</button>
                            </div>
                        </div>
                            <div class="pull-left w100p">
                                <table class="table table-bordered mb0 ">
                                    <thead>
                                        <tr>
                                            <th class=""><input class="allCheck" type="checkbox"></th>
                                            <th>编号</th>
                                            <th>店铺名称</th>
                                            <th>排序</th>
                                            <th>目录标签</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tbody_list">
                                        <!-- <tr>
                                            <td class="td_id">123</td>
                                            <td>123</td>
                                            <td>123</td>
                                            <td><a class="clickDialog" data-toggle="modal"
                                                    data-target="#edit_dialog">选择商品</a></td>
                                        </tr> -->
                                    </tbody>
                                </table>
                            </div>
                            <div class="pull-left tac c0 f14 w100p pre mt10 none" id="footer_page_div">
                                <div>
                                    <div class="pull-left">
                                        <div class="ibox-tools">
                                            <a class="refresh_a">
                                                <i class="fa fa-refresh"></i> 刷新
                                            </a>
                                        </div>
                                    </div>
                                    <span class="under_line cursor_pointer last_span">上一页</span>
                                    <span class="pl20 page_span">1</span>
                                    <span class="pl20 under_line cursor_pointer next_span">下一页</span>
                                    <span class="pl20">共 <span class="count_page_span">1</span> 页</span>
                                    <div class="disib ml20">
                                        每页显示：
                                        <select class="p0 disib page_select">
                                            <option value="" selected="selected">10</option>
                                            <option value="">20</option>
                                            <option value="">30</option>
                                        </select>
                                        条
                                    </div>
                                </div>
                                <div class="record_right_div">
                                    <!--record_right_div pull-right mt10-->
                                    数据库总数量： <span class="counts_span">0</span> 条
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 新增店铺 -->
        <div class="modal inmodal fade" id="add_dialog" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content br8">
                    <div class="modal-header p10 bdno">
                        <button type="button" class="close" data-dismiss="modal"><span
                                aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <span class="modal-title f18">新增店铺</span>
                    </div>
                    <div class="modal-body bg_f p0">
                        <div class="ibox-content p30">
                            <form class="form-horizontal m-t" id="add_form" method="post" enctype="multipart/form-data">
                                <div class="form-group ">
                                    <label class="col-sm-3 control-label pull-left mt10">*店铺名称</label>
                                    <div class="col-sm-5 pull-left mt10">
                                        <input type="text" list="shopList" class="selectbox form-control pull-left"
                                            id="cityName" value="" onfocus="fuzzySearch.call(this)" autocomplete="off"
                                            placeholder="请输入受益方商家,支持模糊查询" />
                                        <div class="picture_click dropDowns" style=""></div>
                                        <div id="shopList" class="selectList">
                                            <!-- <div id="0">全场通用</div>
													<div id="-1">保未来</div> -->
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group ">
                                    <label class="col-sm-3 control-label pull-left">排序</label>
                                    <div class="col-sm-8 pull-left">
                                        <input type="number" class="form-control brandNum" name="sort" value=""
                                            required="" aria-required="true">
                                    </div>
                                </div>
                                <div class="form-group ">
                                    <span class="col-sm-3 control-label pull-left">目录标签：</span>
                                    <div class="col-sm-8 pull-left">
                                        <select name="" class="h30 br_e5e6e7" id="device_type_select">
                                            <option value="8">无</option>
                                            <option value="2">智能安防</option>
                                            <option value="3">家居清洁</option>
                                            <option value="4">小家电</option>
                                        </select>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="modal-footer bdno tac pt0040">
                        <button type="button" class=" btn-white clear_btn_style dialog_btn"
                            data-dismiss="modal">关闭</button>
                        <button type="submit" class=" btn-primary clear_btn_style bdno dialog_btn ml30"
                            id="add_btn">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- <div class="modal inmodal fade" id="" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content br8">
                </div>
            </div>
        </div> -->
        <!--加载遮罩组件-->
        <div class="none" id="wating_show">
            <div class="ibox wating_big_div">
                <div class="zhezhao bg_f"></div>
                <div class="ibox-content wating_content_div ">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-wave">
                            <div class="sk-rect1"></div>
                            <div class="sk-rect2"></div>
                            <div class="sk-rect3"></div>
                            <div class="sk-rect4"></div>\
                            <div class="sk-rect5"></div>
                        </div>
                        <h5 class="f20 c0"><span id="loading_text">正在请求 ，请稍后...... </span>(<span
                                id="second_span">0</span>)秒
                        </h5>
                    </div>
                </div>
            </div>
        </div>
        <script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/bootstrap.min.js?v=3.3.6"></script>
        <script src="js/plugins/peity/jquery.peity.min.js"></script>
        <script src="js/content.min.js?v=1.0.0"></script>
        <script src="js/plugins/layer/laydate/laydate.js"></script>
        <script src="js/plugins/sweetalert/sweetalert.min.js"></script>
        <script src="js/jquery-form.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/plugins/fancybox/jquery.fancybox.js"></script>
        <script src="js/xss.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/common.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/initSearch.js" type="text/javascript"></script>
        <script>
            var dataJson = {
                type: "",
                storeName: "",
                page: 1,
                limit: 10
            }
            var start = 0;
            var changeId = 0;
            var counts = 0;
            var dataList = [];
            var total = 0;
            var deleteTimeOut;
            $(document).ready(function () {
                // IsTokenSave();
                InitTBodyList();
                $("#cityName").bind('input propertychange', function () {
                    //textarea输入框的长度
                    var goodsName = $("#cityName").val();
                    getInitSearch(goodsName);
                });
                // document.getElementById("brandName").addEventListener("onporpertychange", function (e) {
                // });
                $(".querybtn").click(function () {
                    dataJson.storeName = $(".queryInput").val();
                    InitTBodyList();
                })
                $("#add_btn").click(function () {
                    var storeName = $("#cityName").val();
                    var sort = $(".brandNum").val();
                    var selectValue = $('#device_type_select option:selected').val();
                    var storeId = $("#cityName").attr("data-id");
                    addList(storeName, sort, selectValue, storeId);
                })
                $(".addbtn").click(function () {
                    $("#cityName").val("");
                    $(".brandNum").val("");
                })
                $(".page_select").change(function () { //选择一页多少条数据的select
                    dataJson.page = 1;//重置页数
                    $(".page_span").html(1);//重置页数
                    dataJson.limit = $(".page_select option:selected").text();  //设置当前显示数量
                    InitTBodyList();
                });
                $(".last_span").click(function () {  //上一页
                    if (dataJson.page == 1) {
                        TipsAlert("这是最前面的数据了");
                        return false;
                    }
                    dataJson.page--;
                    start = dataJson.page * dataJson.limits;
                    $(".page_span").html(dataJson.page);
                    InitTBodyList();
                });
                $(".next_span").click(function () {  //下一页
                    if (counts == dataJson.page) {
                        TipsAlert("这是最后面的数据了");
                        return false;
                    }
                    dataJson.page++;
                    start = dataJson.page * dataJson.limits;
                    $(".page_span").html(dataJson.page);
                    InitTBodyList();
                });
                $(".refresh_a").click(function () {//刷新按钮
                    location.reload();
                });
            });

            function InitTBodyList() {
                $.ajax({
                    url: urls + common_url.brandStoreJinList,
                    type: 'get',
                    timeout: 30000,
                    data: dataJson,
                    dataType: "json",
                    headers: {
                        'X-Access-Token': userMessage.token,
                    },
                    success: function (res) {
                        CheckLogout(res); //检查是否登陆过期

                        if (res.code == 0) {
                            var html = "";
                            res.data.records.forEach(function (e, i) {
                                html += '<tr>' +
                                    '<td class="td_id"><input class="allCheck" type="checkbox"></td>' +
                                    '<td>' + e.id + '</td>' +
                                    '<td>' + e.storeName + '</td>' +
                                    '<td>' + e.sort + '</td>' +
                                    '<td>' + (e.type == "2" ? "智能安防" : e.type == "3" ? "家居清洁" : e.type == "4" ? "小家电" : "无") + '</td>' +
                                    '<td>' +
                                    '<a class="clickUp">置顶</a>' +
                                    '<a class="clickDelete" data-type="' + e.type + '" data-storeId="' + e.storeId + '">删除</a></td>' +
                                    '</tr>'
                            })
                            $(".counts_span").text(res.data.total);
                            $(".count_page_span").text(res.data.pages);
                            counts = res.data.pages;
                            if (res.data.total == 0) { //显示或隐藏分页
                                $("#footer_page_div").hide();
                            } else {
                                $("#footer_page_div").show();
                            }
                            $("#tbody_list").html(html);
                            //全选按钮
                            $('.allCheck').change(function () {
                                if ($(this).attr("checked") == "checked") {
                                    $("#tbody_list input").attr("checked", "checked");
                                } else {
                                    $("#tbody_list input").removeAttr("checked");
                                }
                            })
                            $(".clickDelete").click(function () {
                                var deleteType = $(this).attr("data-type");
                                var storeId = $(this).attr("data-storeId");
                                deleteList(deleteType, storeId);
                            })
                        }
                    }
                })
            }
            //删除
            function deleteList(deleteType, storeId) {
                swal({
                    title: "请确认是否删除？",
                    text: "删除后将无法恢复，请谨慎操作！",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#5bb7ee",
                    confirmButtonText: "是的，确定删除",
                    cancelButtonText: "让我再考虑一下…",
                    closeOnConfirm: false,
                    closeOnCancel: true
                }, function (yes) {
                    if (yes) {
                        Showload("正在请求删除，请稍后....");
                        deleteTimeOut = setInterval("Timeout(deleteTimeOut)", 1000);
                        $.ajax({
                            url: urls + common_url.deletePavilion,
                            type: 'post',
                            timeout: 30000,
                            data: {
                                type: deleteType,
                                storeId: storeId
                            },
                            dataType: "json",
                            headers: {
                                'X-Access-Token': userMessage.token,
                            },
                            success: function (res) {
                                CheckLogout(res); //检查是否登陆过期

                                if (res.code == "0") {
                                    swal({
                                        title: "删除成功",
                                        text: "删除成功",
                                        type: "success"
                                    }, function () {
                                        location.reload();
                                    });
                                } else {
                                    TipsAlert(res.msg);
                                }
                                InitTime(deleteTimeOut);
                            }
                        })
                    }
                })
            }
            //新增
            function addList(storeName, sort, selectValue, storeId) {
                Showload("正在添加，请稍后....");
                deleteTimeOut = setInterval("Timeout(deleteTimeOut)", 1000);
                $.ajax({
                    url: urls + common_url.sysBrandPavilionSaveOrUpdate,
                    type: 'post',
                    timeout: 30000,
                    data: {
                        storeName: storeName,
                        storeId: storeId,
                        sort: sort,
                        type: selectValue,
                    },
                    headers: {
                        'X-Access-Token': userMessage.token,
                    },
                    dataType: "json",
                    success: function (res) {
                        CheckLogout(res); //检查是否登陆过期

                        if (res.code == "0") {
                            swal({
                                title: "添加成功",
                                text: "添加成功",
                                type: "success",
                            }, function () {
                                location.reload();
                            });
                        } else {
                            TipsAlert(res.msg);
                        }
                        InitTime(deleteTimeOut);
                    }
                })
            }

        </script>
</body>

</html>